package com.lanou3g.hw0419.Q2;

import java.io.*;

/**
 * Created by dllo on 18/4/20.
 */
public class Main {
    //目标是1G
    public static final long TARGET=1024L*0124*1024;
    public static void main(String[] args) {
        new Thread(){
            @Override
            public void run() {
                createFile("a","/Users/dllo/Desktop/作业\\ 2/Q2/a.txt \n");
            }
        }.start();
        createFile("b","/Users/dllo/Desktop/作业\\ 2/Q2/a.txt \n");

    }
    private static void createFile(String fileName,String filePath){
        File file= new File(filePath,fileName);
        BufferedOutputStream bos =null;
        try {
            bos=new BufferedOutputStream(
                    new FileOutputStream(file)
            );
            byte[]buf=new byte[1024];
            long sum=0;
            while (sum<TARGET){
                bos.write(buf);
                sum+=1024L;
            }
            bos.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            if (bos!=null){
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
